package com.concurrent.blockingq;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class BQMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		testSlowConsumer();
		//testSlowProducer();
	}

	private static void testSlowConsumer(){

		BlockingQueue<String> q = new ArrayBlockingQueue<String>(5);  
		BQProducer p1 = new BQProducer("P1", q, 0);
		BQProducer p2 = new BQProducer("P2", q, 0);

		BQConsumer c1 = new BQConsumer("C1", q, 1000);
		
		c1.start();
		p1.start();
		p2.start();

	}
	
	private static void testSlowProducer(){

		BlockingQueue<String> q = new ArrayBlockingQueue<String>(5);  
		BQProducer p1 = new BQProducer("P1", q, 1000);

		BQConsumer c1 = new BQConsumer("C1", q, 0);
		BQConsumer c2 = new BQConsumer("C2", q, 0);
		
		c1.start();
		c2.start();
		p1.start();

	}
}
